<?php
class Zendvn_View_Helper_FlashMessage extends Zend_View_Helper_Abstract{
	
		
	public function flashMessage($attribs = null, $options = null ){
		
		$strAttribs = '';
		if(count($attribs)>0){
			foreach ($attribs as $key => $value){
				$strAttribs .= $key . '="' . $value . '" ';
			}
			
		}
		
		$messages = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->getMessages();
	
        $xhtml = '';
        
        if (!empty($messages)) {
            $xhtml .= '<div  id="flashMessage" ' .  $strAttribs . '>
            			<ul>';
            foreach ($messages as $message) {
                $xhtml .= '<li  class="liMessage">' . current($message) . '</li>';
            }
            $xhtml .= '</ul></div>';
            $script = "$(document).ready(function() {
							$('#flashMessage').slideDown('slow').delay(5000).slideUp('slow');
						});
            		  ";
            $this->view->headScript()->appendScript($script);
        }
        
        return $xhtml;
	}
}